package com.allprs.hmcs.service.impl;

import com.allprs.common.core.domain.AjaxResult;
import com.allprs.common.utils.StringUtils;
import com.allprs.hmcs.entity.NaturalWater;
import com.allprs.hmcs.mapper.NaturalWaterMapper;
import com.allprs.hmcs.pojo.reqBo.NaturalQueryBo;
import com.allprs.hmcs.service.INaturalWaterService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjf
 * @描述: 自然水体service
 * @date 2024年06月11日
 * @version: 1.0
 */

@Service
public class NaturalWaterServiceImpl implements INaturalWaterService {

    @Resource
    private NaturalWaterMapper naturalWaterMapper;


    @Override
    public AjaxResult getNaturalInfo(NaturalQueryBo queryBo) {
        QueryWrapper<NaturalWater> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(queryBo.getName()), "name", queryBo.getName())
                .eq(StringUtils.isNotBlank(queryBo.getType()), "type", queryBo.getType())
                .eq(queryBo.getId() != 0, "id", queryBo.getId());

        List<NaturalWater> naturalWaters = naturalWaterMapper.selectList(queryWrapper);

        return AjaxResult.success(naturalWaters);

    }
}
